Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Server Version in Yorkie CLI #938

Conversation

hyun98
Copy link
Contributor

@hyun98 hyun98 commented Jul 22, 2024

What this PR does / why we need it:

Add the functionality to display the version of connected Yorkie server in the version command

Which issue(s) this PR fixes:

Fixes #870

Special notes for your reviewer:

  • The version information can be viewed by converting it into yaml or json format using the --output, -o flag.
    This flag accepts json and yaml strings and converts them to the appropriate format for display.
  • In order to solely check the version of the client CLI without considering the server's version, the --client flag has been included.
  • The development of this feature was inspired by examining the kubectl code.

Does this PR introduce a user-facing change?:

NONE

Additional documentation:

$ yorkie version -h

Print the version number of Yorkie

Usage:
  yorkie version [flags]

Flags:
      --client          Shows client version only. (no server required)
  -h, --help            help for version
  -o, --output string   One of 'yaml' or 'json'.

Global Flags:
      --rpc-addr string   Address of the rpc server (default "localhost:8080")

Checklist:

  • Added relevant tests or not required
  • Didn't break anything

Summary by CodeRabbit

  • New Features

    • Introduced a new method to retrieve the server version, providing users with version details including Yorkie version, Go version, and build date.
    • Enhanced the version command functionality to support output format validation and retrieval of the server version.
    • Improved output formatting options for the version command, allowing users to choose between standard, YAML, or JSON outputs.
  • Bug Fixes

    • Improved error handling during server version retrieval, ensuring clearer feedback for users.
  • Tests

    • Added new test cases to validate the functionality of the server version retrieval method.

@CLAassistant
Copy link

CLAassistant commented Jul 22, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

coderabbitai bot commented Jul 22, 2024

Walkthrough

The recent updates enhance the Yorkie CLI by introducing a GetServerVersion feature, enabling users to retrieve and display the server version alongside client version details. This functionality improves usability and transparency, facilitating better debugging and maintenance. The changes span multiple files, including client code, API specifications, and testing frameworks, ensuring seamless integration and robustness.

Changes

Files Change Summary
admin/client.go, cmd/yorkie/version.go, server/rpc/testcases/testcases.go Added GetServerVersion method to retrieve server version and improved CLI command functionality.
api/docs/yorkie/v1/admin.openapi.yaml Introduced a new API endpoint and schemas for server version retrieval.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant YorkieCLI
    participant AdminService
    participant Server

    User->>YorkieCLI: Request server version
    YorkieCLI->>AdminService: Call GetServerVersion()
    AdminService->>Server: Retrieve version info
    Server-->>AdminService: Return version details
    AdminService-->>YorkieCLI: Send version info
    YorkieCLI-->>User: Display version info
Loading

Assessment against linked issues

Objective Addressed Explanation
Show server version in Yorkie CLI (870)

🐰 In the meadow, bright and free,
A server's version calls to me.
With each command, a joyful dance,
Yorkie's version takes a chance!
The CLI now sings, a version bright,
For users' ease, it's pure delight! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b494fa2 and 977ecf8.

Files ignored due to path filters (2)
  • api/yorkie/v1/admin.pb.go is excluded by !**/*.pb.go
  • api/yorkie/v1/resources.pb.go is excluded by !**/*.pb.go
Files selected for processing (11)
  • admin/client.go (1 hunks)
  • api/docs/yorkie/v1/admin.openapi.yaml (5 hunks)
  • api/docs/yorkie/v1/resources.openapi.yaml (1 hunks)
  • api/types/version_info.go (1 hunks)
  • api/yorkie/v1/admin.proto (2 hunks)
  • api/yorkie/v1/resources.proto (2 hunks)
  • api/yorkie/v1/v1connect/admin.connect.go (9 hunks)
  • cmd/yorkie/version.go (1 hunks)
  • server/rpc/admin_server.go (2 hunks)
  • server/rpc/server_test.go (1 hunks)
  • server/rpc/testcases/testcases.go (1 hunks)
Additional context used
golangci-lint
cmd/yorkie/version.go

27-27: File is not goimports-ed with -local github.com/yorkie-team/yorkie

(goimports)

Additional comments not posted (23)
api/types/version_info.go (2)

3-10: LGTM!

The VersionInfo struct is well-defined and includes fields for both client and server versions.


12-22: LGTM!

The VersionDetail struct is well-defined and includes fields for version details.

api/yorkie/v1/admin.proto (2)

46-46: LGTM!

The GetServerVersion RPC method is well-defined and follows best practices for gRPC services.


171-175: LGTM!

The GetServerVersionResponse message type is well-defined and includes fields for version details.

cmd/yorkie/version.go (4)

35-118: LGTM!

The newVersionCmd function is well-defined and follows best practices for Cobra commands.


124-131: LGTM!

The Validate function is well-defined and follows best practices for validation functions.


133-139: LGTM!

The getYorkieClientVersion function is well-defined and follows best practices for version functions.


140-157: LGTM!

The init function is well-defined and follows best practices for initialization functions.

server/rpc/server_test.go (1)

214-216: LGTM! Verify the implementation of RunAdminGetServerVersionTest.

The new test case is approved.

However, ensure that the RunAdminGetServerVersionTest function is correctly implemented.

Verification successful

The implementation of RunAdminGetServerVersionTest is correct.

The function correctly retrieves the server version and asserts that there are no errors and the response is not nil.

  • server/rpc/testcases/testcases.go lines 1019-1030
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `RunAdminGetServerVersionTest`.

# Test: Search for the function implementation. Expect: Correct implementation of the function.
ast-grep --lang go --pattern $'func RunAdminGetServerVersionTest($_, $_) {
  $$$
}'

Length of output: 861

api/yorkie/v1/resources.proto (2)

22-22: LGTM!

The new import statement for google/protobuf/empty.proto is approved.


380-380: LGTM!

The new message type Empty is approved.

admin/client.go (1)

357-370: LGTM! Verify the usage of types.VersionDetail.

The new method GetServerVersion is approved.

However, ensure that the types.VersionDetail struct is correctly defined and used.

Verification successful

Verify the usage of types.VersionDetail.

The types.VersionDetail struct is correctly defined in ./api/types/version_info.go. Now, let's ensure it is used appropriately throughout the codebase.


Verified: The types.VersionDetail struct is correctly defined and used.

  • The types.VersionDetail struct is properly defined with the necessary fields.
  • It is consistently and correctly used across the codebase, including in the GetServerVersion method.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `types.VersionDetail`.

# Test: Search for the struct definition. Expect: Correct definition and usage of the struct.
ast-grep --lang go --pattern $'type VersionDetail struct {
  $$$
}'

Length of output: 630


Script:

#!/bin/bash
# Description: Verify the usage of `types.VersionDetail` throughout the codebase.

# Test: Search for all instances where `types.VersionDetail` is used.
rg 'VersionDetail' -A 5

Length of output: 2014

server/rpc/admin_server.go (1)

440-450: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to GetServerVersion are correctly integrated.

Verification successful

Function usage verified and correctly integrated.

The GetServerVersion function is used across multiple files, including test cases, client implementations, and generated protobuf files. All instances appear to be correctly integrated.

  • server/rpc/server_test.go
  • server/rpc/testcases/testcases.go
  • cmd/yorkie/version.go
  • admin/client.go
  • api/yorkie/v1/admin.pb.go
  • api/yorkie/v1/v1connect/admin.connect.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `GetServerVersion` are correctly integrated.

# Test: Search for the function usage. Expect: Only occurances of the new function.
rg --type go -A 5 $'GetServerVersion'

Length of output: 12410

api/yorkie/v1/v1connect/admin.connect.go (5)

107-107: LGTM!

The method signature for GetServerVersion is correctly added to the AdminServiceClient interface.


296-296: LGTM!

The method signature for GetServerVersion is correctly added to the AdminServiceHandler interface.


276-279: LGTM!

The method implementation for GetServerVersion is correctly added to the adminServiceClient struct.


370-374: LGTM!

The handler for the GetServerVersion method is correctly added to the NewAdminServiceHandler.


466-468: LGTM!

The method stub for GetServerVersion is correctly added to the UnimplementedAdminServiceHandler.

server/rpc/testcases/testcases.go (1)

1018-1030: LGTM! But verify the test function usage in the codebase.

The test function RunAdminGetServerVersionTest is correctly implemented.

However, ensure that the test function is correctly integrated and executed in the test suite.

Verification successful

The test function RunAdminGetServerVersionTest is correctly integrated and executed in the test suite.

  • server/rpc/server_test.go: The test function is invoked here, ensuring it is part of the test execution.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the test function usage in the codebase.

# Test: Search for the test function usage. Expect: Only occurances of the new test function.
rg --type go -A 5 $'RunAdminGetServerVersionTest'

Length of output: 837

api/docs/yorkie/v1/resources.openapi.yaml (1)

376-380: LGTM! The yorkie.v1.Empty schema is well-defined.

The schema correctly represents an empty object with additionalProperties set to false, ensuring no unexpected properties are included.

api/docs/yorkie/v1/admin.openapi.yaml (3)

61-72: LGTM! The new endpoint /yorkie.v1.AdminService/GetServerVersion is well-defined.

The endpoint correctly uses the POST method with an empty request body and a detailed response schema.


219-227: LGTM! The schema yorkie.v1.AdminService.GetServerVersion.yorkie.v1.Empty correctly references yorkie.v1.Empty.

This ensures consistency and clarity in the API documentation.


799-819: LGTM! The schema yorkie.v1.GetServerVersionResponse is well-defined.

The schema includes appropriate fields for buildDate, goVersion, and yorkieVersion, with additionalProperties set to false.

cmd/yorkie/version.go Outdated Show resolved Hide resolved
Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code in the PR generally looks good, but there are a few edge cases that need to be addressed. Currently, the behavior varies in different scenarios:

A. When the CLI has an authenticated context:

The user can log in, view contexts, and see both client and server version information.

$ yorkie login -u admin -p admin --insecure
$ yorkie context ls
 CURRENT  RPC ADDR        INSECURE  TOKEN
 *        localhost:8080  true      eyJhbGciOi...hxtu4u7_jE
$ yorkie version
Yorkie Client: 0.4.27
Go: go1.22.1
Build Date: 2024-07-23
Yorkie Server: 0.4.27
Go: go1.22.1
Build Date: 2024-07-23

B. When the CLI has no context:

The user can see client version information, but receives an error when trying to fetch the server version.

$ yorkie logout
$ yorkie version
Yorkie Client: 0.4.27
Go: go1.22.1
Build Date: 2024-07-23
Error fetching server version: auth for localhost:8080 does not exist

C. When the CLI requests version information from an old server:

The user sees client version information but gets an authentication error for the server version.

$ yorkie version --rpc-addr api.yorkie.dev:443
Yorkie Client: 0.4.27
Go: go1.22.1
Build Date: 2024-07-23
Error fetching server version: auth for api.yorkie.dev:443 does not exist

D. Questions and suggestions for improvement:

Q) Should we allow users to view the server version without authentication? This could be beneficial for troubleshooting and version compatibility checks.

Q) How should we handle different scenarios?

  • When the server endpoint is incorrect or the server is not running: We should provide a clear error message indicating connection issues.
  • When the server is running an older version without the version API: We should gracefully handle this case, perhaps by showing the client version and indicating that the server version is unavailable or outdated.

@hyun98
Copy link
Contributor Author

hyun98 commented Jul 23, 2024

First of all, thank you very much for your review. @hackerwins

D. Questions and suggestions for improvement:

Q) Should we allow users to view the server version without authentication? This could be beneficial for troubleshooting and version compatibility checks.

A) I agree that checking the server version without authentication has several advantages. So, I would like to add a flag that can check the version of a specific addr without authentication. For example, options like --no-auth. Would this be a good option name? I always worry about naming.
Additionally, I'm asking just in case, but I understand that you don't mean to remove the authentication itself for version checking, right?

Q) How should we handle different scenarios?

  • When the server endpoint is incorrect or the server is not running: We should provide a clear error message indicating connection issues.

A) Thank you. If the server version is not loaded properly, I need to modify it to display a more appropriate error message.

  • When the server is running an older version without the version API: We should gracefully handle this case, perhaps by showing the client version and indicating that the server version is unavailable or outdated.

A) Likewise, we need to show an appropriate message regarding the case you mentioned. For example, Phrases like: 'server version checking is only supported if the server version is 0.4.27 or higher.'

Lastly, there was an error in my code. I tried to use auth, but there was a problem with only loading auth that does not fit the current context because config.Preload was not performed, so I will fix it together.

Thank you :)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 977ecf8 and b758913.

Files selected for processing (1)
  • cmd/yorkie/version.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • cmd/yorkie/version.go

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b758913 and 9990f06.

Files ignored due to path filters (1)
  • api/yorkie/v1/admin.pb.go is excluded by !**/*.pb.go
Files selected for processing (6)
  • admin/client.go (1 hunks)
  • api/docs/yorkie/v1/admin.openapi.yaml (4 hunks)
  • api/yorkie/v1/admin.proto (2 hunks)
  • api/yorkie/v1/v1connect/admin.connect.go (9 hunks)
  • server/rpc/admin_server.go (2 hunks)
  • server/rpc/testcases/testcases.go (1 hunks)
Files skipped from review as they are similar to previous changes (6)
  • admin/client.go
  • api/docs/yorkie/v1/admin.openapi.yaml
  • api/yorkie/v1/admin.proto
  • api/yorkie/v1/v1connect/admin.connect.go
  • server/rpc/admin_server.go
  • server/rpc/testcases/testcases.go

@hackerwins
Copy link
Member

A) I agree that checking the server version without authentication has several advantages. So, I would like to add a flag that can check the version of a specific addr without authentication. For example, options like --no-auth. Would this be a good option name? I always worry about naming.
Additionally, I'm asking just in case, but I understand that you don't mean to remove the authentication itself for version checking, right?

It would be better to remove authentication entirely for checking the server version. Version is often considered public information and it improves the experience for developers who need to quickly check version. I am also curious about whether kubectl's version command checks authentication. 🤔

@hyun98
Copy link
Contributor Author

hyun98 commented Jul 26, 2024

It would be better to remove authentication entirely for checking the server version. Version is often considered public information and it improves the experience for developers who need to quickly check version. I am also curious about whether kubectl's version command checks authentication. 🤔

That's a relief, I asked just in case. Now I understood your intentions correctly.
I will try to remove authentication with the version check command. I think removing authentication would be a better experience during the development process.

However, there is one thing that concerns me. I don't know much about security, but I wonder if there will be any security issues due to server version exposure. 🤔

Additionally, kubectl always goes through an authentication process to obtain the server's version information (only when there is no --client option). To obtain version information, the context and auth existing in $HOME/.kube/config are used. This is because the k8s api-server is accessed through information.

@krapie
Copy link
Member

krapie commented Jul 26, 2024

When thinking about who will be using this feature, I think the internal developers who combined Yorkie with their system will use this feature to check or troubleshoot something. So I'm not sure about the necessity of exposing this feature to public.

However, there is one thing that concerns me. I don't know much about security, but I wonder if there will be any security issues due to server version exposure. 🤔

@hyun98 I think there can be a malicious attack by penetrating the weakness of the certain server version exposed by this feature.

@hyun98 hyun98 force-pushed the feature/#870-show-server-version-in-yorkie-cli branch from 9990f06 to 742d6d1 Compare July 28, 2024 15:39
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9990f06 and 742d6d1.

Files ignored due to path filters (1)
  • api/yorkie/v1/admin.pb.go is excluded by !**/*.pb.go
Files selected for processing (9)
  • admin/client.go (1 hunks)
  • api/docs/yorkie/v1/admin.openapi.yaml (4 hunks)
  • api/types/version_info.go (1 hunks)
  • api/yorkie/v1/admin.proto (2 hunks)
  • api/yorkie/v1/v1connect/admin.connect.go (9 hunks)
  • cmd/yorkie/version.go (1 hunks)
  • server/rpc/admin_server.go (2 hunks)
  • server/rpc/server_test.go (1 hunks)
  • server/rpc/testcases/testcases.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • api/types/version_info.go
Files skipped from review as they are similar to previous changes (5)
  • admin/client.go
  • api/yorkie/v1/admin.proto
  • cmd/yorkie/version.go
  • server/rpc/server_test.go
  • server/rpc/testcases/testcases.go
Additional comments not posted (11)
api/yorkie/v1/v1connect/admin.connect.go (6)

115-115: LGTM!

The method signature in the AdminServiceClient interface is correctly defined.


328-328: LGTM!

The method signature in the AdminServiceHandler interface is correctly defined.


306-309: LGTM!

The method implementation in the adminServiceClient struct is correctly defined.


520-522: LGTM!

The method implementation in the UnimplementedAdminServiceHandler struct is correctly defined.


412-416: LGTM!

The handler for the GetServerVersion RPC is correctly defined.


449-450: LGTM!

The HTTP handler for the GetServerVersion RPC is correctly defined.

api/docs/yorkie/v1/admin.openapi.yaml (5)

85-96: LGTM!

The endpoint for retrieving the server version is correctly defined.


261-269: LGTM!

The request body schema for retrieving the server version is correctly defined.


415-423: LGTM!

The response schema for retrieving the server version is correctly defined.


901-905: LGTM!

The schema for the GetServerVersionRequest is correctly defined.


906-926: LGTM!

The schema for the GetServerVersionResponse is correctly defined.

server/rpc/admin_server.go Show resolved Hide resolved
cmd/yorkie/version.go Outdated Show resolved Hide resolved
@krapie krapie added the enhancement 🌟 New feature or request label Aug 4, 2024
@krapie krapie self-requested a review August 4, 2024 12:36
cmd/yorkie/version.go Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 742d6d1 and 781d639.

Files selected for processing (2)
  • cmd/yorkie/version.go (1 hunks)
  • test/bench/tree_editing_bench_test.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • test/bench/tree_editing_bench_test.go
Additional comments not posted (6)
cmd/yorkie/version.go (6)

20-33: Imports LGTM!

The new imports are necessary for the added functionality.


37-40: Variable Declarations LGTM!

The new variables clientOnly and output are necessary for the added functionality.


41-137: Function newVersionCmd LGTM with minor suggestions.

The logic for validation and concurrent processing is well-implemented. However, consider the following improvements:

  1. Error Handling: Enhance error handling by providing more detailed messages for different error cases.
  2. Code Readability: Improve code readability by breaking down the function into smaller helper functions.

Example refactor for error handling:

func handleServerError(cmd *cobra.Command, serverErr error) {
	cmd.Printf("Error fetching server version: ")

	connectErr := new(connect.Error)
	if errors.As(serverErr, &connectErr) {
		switch connectErr.Code() {
		case connect.CodeUnimplemented:
			cmd.Printf("The server does not support this operation. You might need to check your server version.\n")
		}
	} else {
		cmd.Print(serverErr)
	}
}

And then call handleServerError(cmd, serverErr) in place of the current error handling logic.


144-151: Function Validate LGTM!

The function correctly validates the output format.


153-159: Function getYorkieClientVersion LGTM!

The function correctly returns the client version details.


160-177: Function init LGTM!

The function correctly adds the new version command and sets up the flags.

Copy link

codecov bot commented Aug 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.34%. Comparing base (52d2732) to head (781d639).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #938      +/-   ##
==========================================
+ Coverage   51.31%   51.34%   +0.02%     
==========================================
  Files          71       71              
  Lines       10679    10685       +6     
==========================================
+ Hits         5480     5486       +6     
  Misses       4650     4650              
  Partials      549      549              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

cmd/yorkie/version.go Outdated Show resolved Hide resolved
@hackerwins hackerwins self-requested a review August 5, 2024 04:49
Copy link
Member

@krapie krapie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution 😄
I have left some comments regarding the code style and etc.

FYI: After this PR merges, you might have to update corresponding Yorkie CLI Docs for this CLI feature.

admin/client.go Outdated Show resolved Hide resolved
server/rpc/testcases/testcases.go Show resolved Hide resolved
cmd/yorkie/version.go Outdated Show resolved Hide resolved
cmd/yorkie/version.go Outdated Show resolved Hide resolved
cmd/yorkie/version.go Outdated Show resolved Hide resolved
cmd/yorkie/version.go Outdated Show resolved Hide resolved
cmd/yorkie/version.go Outdated Show resolved Hide resolved
Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work on this PR. I have a suggestion regarding the use of goroutines.

cmd/yorkie/version.go Outdated Show resolved Hide resolved
@hyun98
Copy link
Contributor Author

hyun98 commented Aug 6, 2024

Thanks for your comment.
I agree that the current code lacks the advantage of goroutines.
I'll remove it as it increases complexity such as error handling... without any significant advantage.
Thanks to this, it gave me an opportunity to think more about using goroutines.

- remove goroutine has no advantage
- method extract for readability
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
cmd/yorkie/version.go (1)

73-93: Consider enhancing error handling in getServerVersion.

While the function correctly retrieves the server version, consider adding more context to error messages for better debugging.

-  return nil, err
+  return nil, fmt.Errorf("failed to get server version: %w", err)
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 781d639 and 61f2036.

Files selected for processing (3)
  • admin/client.go (1 hunks)
  • cmd/yorkie/version.go (1 hunks)
  • server/rpc/testcases/testcases.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • admin/client.go
  • server/rpc/testcases/testcases.go
Additional comments not posted (8)
cmd/yorkie/version.go (8)

20-32: Imports look good.

The imports are appropriate for the functionalities implemented in this file.


36-39: Variable declarations are appropriate.

The variables clientOnly and output are well-named and serve their intended purpose.


40-67: Function newVersionCmd is well-structured.

The function correctly sets up the version command with validation and error handling.


95-101: Function getClientVersion is correct.

The function correctly returns the client version details.


103-121: Function printServerError is adequate with a TODO for improvement.

The function handles server errors and includes a TODO for future improvements.


124-150: Function printVersionInfo is well-implemented.

The function provides flexible output options for version information.


153-160: Function ValidateOptions is correct.

The function correctly validates the output format options.


161-178: init function is well-structured.

The function correctly initializes the version command with appropriate flags.

@hackerwins hackerwins self-requested a review August 9, 2024 01:29
Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Thanks for your contribution.

@hackerwins hackerwins merged commit c89e495 into yorkie-team:main Aug 9, 2024
4 checks passed
hackerwins pushed a commit that referenced this pull request Aug 9, 2024
This commit adds the functionality to display the version of connected
Yorkie server in the version command.

The version information can be viewed by converting it into yaml or
json format using the --output, -o flag. This flag accepts json and
yaml strings and converts them to the appropriate format for display.
In order to solely check the version of the client CLI without
considering the server's version, the --client flag has been included.
The development of this feature was inspired by examining the kubectl.
hackerwins pushed a commit that referenced this pull request Aug 9, 2024
This commit adds the functionality to display the version of connected
Yorkie server in the version command.

The version information can be viewed by converting it into yaml or
json format using the --output, -o flag. This flag accepts json and
yaml strings and converts them to the appropriate format for display.
In order to solely check the version of the client CLI without
considering the server's version, the --client flag has been included.
The development of this feature was inspired by examining the kubectl.
hackerwins pushed a commit that referenced this pull request Aug 9, 2024
This commit adds the functionality to display the version of connected
Yorkie server in the version command.

The version information can be viewed by converting it into yaml or
json format using the --output, -o flag. This flag accepts json and
yaml strings and converts them to the appropriate format for display.
In order to solely check the version of the client CLI without
considering the server's version, the --client flag has been included.
The development of this feature was inspired by examining the kubectl.
raararaara pushed a commit that referenced this pull request Oct 7, 2024
This commit adds the functionality to display the version of connected
Yorkie server in the version command.

The version information can be viewed by converting it into yaml or
json format using the --output, -o flag. This flag accepts json and
yaml strings and converts them to the appropriate format for display.
In order to solely check the version of the client CLI without
considering the server's version, the --client flag has been included.
The development of this feature was inspired by examining the kubectl.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🌟 New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Show Server Version in Yorkie CLI
4 participants